package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.entity.beautyescort.RewardResult;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.beautyescort.BeautyEscortModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_GET_UNION_RANK_REWARD_FROM_CROSS, desc = "领取商会排行奖励")
public class BeautyEscortGetUnionRankRewardCmdFromCross extends AbstractCommand {

    BeautyEscortProto.BeautyEscortGetUnionRankRewardRespMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = BeautyEscortProto.BeautyEscortGetUnionRankRewardRespMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        RewardResult rewardResult = player.getModule(BeautyEscortModule.class).getUnionRankRewardFromCross(reqMsg.getGroupId(), reqMsg.getWeekId(), reqMsg.getRank());
        BeautyEscortProto.BeautyEscortGetUnionRankRewardRespMsg.Builder respMsg = BeautyEscortProto.BeautyEscortGetUnionRankRewardRespMsg.newBuilder();
        respMsg.setWeekId(reqMsg.getWeekId());
        respMsg.setRet(rewardResult.getRet());
        respMsg.setRank(reqMsg.getRank());
        if(!StringUtils.isNullOrEmpty(rewardResult.getReward())) {
            respMsg.setReward(rewardResult.getReward());
        }
        player.sendPacket(Protocol.U_BEAUTY_ESCORT_GET_UNION_RANK_REWARD, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
